#include <QtGui>

#include "basicinq.h"
#include "ui_basicinq.h"

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>

#include <fstream>
#include <iostream>
#include <string>
#include <vector>

#define WS 0
#define BS 1
#define S  2
#define T  3
#define I  4
#define Wp 5
#define Sg 6
#define Nv 7
#define Ld 8
#define Speed 9

#define HEAD 0
#define CHEST 1
#define ABDOMEN 2
#define RARM 3
#define LARM 4
#define GROIN 5
#define RLEG 6
#define LLEG 7

#define AVE 0
#define DICE_NUM 1
#define DICE_TYPE 2

#define PRONE 0
#define SS 1
#define KO 2
#define DEAD 3

#define RIGHT 0
#define LEFT 1


using namespace std;

vector<string> class_names;
vector< vector< vector<int> > >  class_stats;

vector<string> char_names;
vector< vector<int> > char_stats;
vector< vector<int> > char_armour;
vector< vector<int> > char_IV;
vector<int> char_IT;
vector< vector<bool> > char_bleed;
vector< vector<bool> > char_status;
vector<int> char_stun;
vector<int> char_KB;
vector< vector<int> > char_parry;
vector<int> char_speedLoss;
vector< vector<bool> > armour_damage;
vector< vector<int> > heal_count;


int char_index = -1;

BasicINQ::BasicINQ(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::BasicINQ)
{
    string line, name;
    string::iterator str_it;
    vector< vector<int> > stats;
    vector<int> generator;
    int number;

    ui->setupUi(this);


    ui_SelectClass = qFindChild<QComboBox*>(this,"SelectClass");
    ui_SelectChar = qFindChild<QComboBox*>(this,"SelectChar");

    ui_Generate_button = qFindChild<QPushButton*>(this, "Generate_button");
    ui_Create_button = qFindChild<QPushButton*>(this, "Create_button");

    ui_WS_box =    qFindChild<QLabel*>(this,"WS_box");
    ui_BS_box =    qFindChild<QLabel*>(this,"BS_box");
    ui_S_box  =    qFindChild<QLabel*>(this, "S_box");
    ui_T_box  =    qFindChild<QLabel*>(this, "T_box");
    ui_I_box  =    qFindChild<QLabel*>(this, "I_box");
    ui_Wp_box =    qFindChild<QLabel*>(this,"Wp_box");
    ui_Sg_box =    qFindChild<QLabel*>(this,"Sg_box");
    ui_Nv_box =    qFindChild<QLabel*>(this,"Nv_box");
    ui_Ld_box =    qFindChild<QLabel*>(this,"Ld_box");
    ui_Speed_box = qFindChild<QLabel*>(this,"Speed_box");

    ui_WS_box_2 =    qFindChild<QLabel*>(this,"WS_box_2");
    ui_BS_box_2 =    qFindChild<QLabel*>(this,"BS_box_2");
    ui_S_box_2  =    qFindChild<QLabel*>(this, "S_box_2");
    ui_T_box_2  =    qFindChild<QLabel*>(this, "T_box_2");
    ui_I_box_2  =    qFindChild<QLabel*>(this, "I_box_2");
    ui_Wp_box_2 =    qFindChild<QLabel*>(this,"Wp_box_2");
    ui_Sg_box_2 =    qFindChild<QLabel*>(this,"Sg_box_2");
    ui_Nv_box_2 =    qFindChild<QLabel*>(this,"Nv_box_2");
    ui_Ld_box_2 =    qFindChild<QLabel*>(this,"Ld_box_2");
    ui_Speed_box_2 = qFindChild<QLabel*>(this,"Speed_box_2");
    ui_IT_spin =     qFindChild<QSpinBox*>(this,"IT_spin");

    ui_Head_spin =    qFindChild<QSpinBox*>(this,"Head_spin");
    ui_Chest_spin =   qFindChild<QSpinBox*>(this,"Chest_spin");
    ui_Abdomen_spin = qFindChild<QSpinBox*>(this,"Abdomen_spin");
    ui_RArm_spin =    qFindChild<QSpinBox*>(this,"RArm_spin");
    ui_LArm_spin =    qFindChild<QSpinBox*>(this,"LArm_spin");
    ui_Groin_spin =   qFindChild<QSpinBox*>(this,"Groin_spin");
    ui_RLeg_spin =    qFindChild<QSpinBox*>(this,"RLeg_spin");
    ui_LLeg_spin =    qFindChild<QSpinBox*>(this,"LLeg_spin");

    ui_Head_combo =    qFindChild<QComboBox*>(this,"Head_combo");
    ui_Chest_combo =   qFindChild<QComboBox*>(this,"Chest_combo");
    ui_Abdomen_combo = qFindChild<QComboBox*>(this,"Abdomen_combo");
    ui_RArm_combo =    qFindChild<QComboBox*>(this,"RArm_combo");
    ui_LArm_combo =    qFindChild<QComboBox*>(this,"LArm_combo");
    ui_Groin_combo =   qFindChild<QComboBox*>(this,"Groin_combo");
    ui_RLeg_combo =    qFindChild<QComboBox*>(this,"RLeg_combo");
    ui_LLeg_combo =    qFindChild<QComboBox*>(this,"LLeg_combo");

    ui_Head_check =    qFindChild<QCheckBox*>(this,"Head_check");
    ui_Chest_check =   qFindChild<QCheckBox*>(this,"Chest_check");
    ui_Abdomen_check = qFindChild<QCheckBox*>(this,"Abdomen_check");
    ui_RArm_check =    qFindChild<QCheckBox*>(this,"RArm_check");
    ui_LArm_check =    qFindChild<QCheckBox*>(this,"LArm_check");
    ui_Groin_check =   qFindChild<QCheckBox*>(this,"Groin_check");
    ui_RLeg_check =    qFindChild<QCheckBox*>(this,"RLeg_check");
    ui_LLeg_check =    qFindChild<QCheckBox*>(this,"LLeg_check");

    ui_Prone_check =   qFindChild<QCheckBox*>(this,"Prone_check");
    ui_KB_spin =       qFindChild<QSpinBox*>(this,"KB_spin");
    ui_SS_check =      qFindChild<QCheckBox*>(this,"SS_check");
    ui_KO_check =      qFindChild<QCheckBox*>(this,"KO_check");
    ui_Dead_check =    qFindChild<QCheckBox*>(this,"Dead_check");
    ui_Stun_spin =     qFindChild<QSpinBox*>(this,"Stun_spin");

    ui_Head_radio =    qFindChild<QRadioButton*>(this,"Head_radio");
    ui_Chest_radio =   qFindChild<QRadioButton*>(this,"Chest_radio");
    ui_Abdomen_radio = qFindChild<QRadioButton*>(this,"Abdomen_radio");
    ui_RArm_radio =    qFindChild<QRadioButton*>(this,"RArm_radio");
    ui_LArm_radio =    qFindChild<QRadioButton*>(this,"LArm_radio");
    ui_Groin_radio =   qFindChild<QRadioButton*>(this,"Groin_radio");
    ui_RLeg_radio =    qFindChild<QRadioButton*>(this,"RLeg_radio");
    ui_LLeg_radio =    qFindChild<QRadioButton*>(this,"LLeg_radio");
    ui_IT_radio =      qFindChild<QRadioButton*>(this,"IT_radio");
    ui_Location_radio= qFindChild<QRadioButton*>(this,"Location_radio");

    ui_Injur_spin = qFindChild<QSpinBox*>(this, "Injur_spin");
    ui_Location_spin = qFindChild<QSpinBox*>(this, "Location_spin");

    ui_Injur_button =  qFindChild<QPushButton*>(this, "Injur_button");
    ui_Heal_button =   qFindChild<QPushButton*>(this, "Heal_button");

    ui_Turn_button =   qFindChild<QPushButton*>(this, "Turn_button");
    ui_Turn_spin   =   qFindChild<QSpinBox*>(this, "Turn_spin");

    ui_Dodge_button =  qFindChild<QPushButton*>(this, "Dodge_button");
    ui_RParry_spin = qFindChild<QSpinBox*>(this, "RParry_spin");
    ui_LParry_spin = qFindChild<QSpinBox*>(this, "LParry_spin");


    //--load INQcharacters.txt--
    ifstream INQchar_file ( "INQcharacters.txt" );

    if(INQchar_file.is_open())
    {
        while(! INQchar_file.eof() )
        {
            getline(INQchar_file,line);

            if(line != "") //ignore skipped lines
            {
                name = ""; //write out the name of this class of Inquisitor character
                for ( str_it = line.begin() ; str_it < line.end(); str_it++ )
                {
                    if(*str_it == ' ')
                    {
                        break;
                    }
                    else if (*str_it == '_')
                    {
                        name += ' ';
                    }
                    else
                    {
                        name += *str_it;
                    }
                }

                //enter name into vecter class_names to be used by the combo box
                class_names.push_back(name);

                //enter in stats for the INQclass
                stats.clear();


                for(int i = WS; i <= Ld; i++)
                {
                    generator.clear();

                    //=== WS ===
                    while(true) //search for ave WS
                    {
                        if(isdigit(*str_it)) //found the ave WS
                        {
                            name = *str_it;
                            str_it++;
                            while(isdigit(*str_it))  //contine to gather up the full length of the number
                            {
                                name += *str_it;
                                str_it++;
                            }

                            number = atoi(name.c_str());

                            generator.push_back(number); // enter in the average WS

                            while(true)  //search for number of dice for the WS roll
                            {
                                if(isdigit(*str_it)) //found number of dice for WS roll
                                {
                                    name = *str_it;
                                    str_it++;
                                    while(isdigit(*str_it)) //continue to gather up the full length of the number
                                    {
                                        name += *str_it;
                                        str_it++;
                                    }

                                    number = atoi(name.c_str());

                                    generator.push_back(number); // enter in the number of dice to roll for the WS roll

                                    while(true)    //search for the type of dice for the WS roll
                                    {
                                        if(isdigit(*str_it)) //found the type of dice for the WS roll
                                        {
                                            name = *str_it;
                                            str_it++;
                                            while(isdigit(*str_it)) //continue to gather up the full length of the number
                                            {
                                                name += *str_it;
                                                str_it++;
                                            }

                                            number = atoi(name.c_str());

                                            generator.push_back(number); // enter in the type of dice to roll for the WS roll

                                            break;
                                        }
                                        else if(str_it < line.end())    //if you have not reached the end of the line...
                                        {
                                            str_it++;   //continue to search
                                        }
                                        else
                                        {
                                            generator.push_back(0);     //otherwise you have reached the end of the line.  give up search and enter in zeros instead.
                                            break;
                                        }
                                    }//type of dice while loop

                                    break;
                                }
                                else if(str_it < line.end())  //if you have not reached the end of the line...
                                {
                                    str_it++;   //continue to search
                                }
                                else
                                {
                                    generator.push_back(0);     //otherwise you have reached the end of the line.  give up search and enter in zeros instead.
                                    generator.push_back(0);
                                    break;
                                }
                            }//number of dice while loop

                            break;

                        }
                        else if(str_it < line.end())  //if you have not reached the end of the line...
                        {
                            str_it++;  //continue to search
                        }
                        else
                        {
                            generator.assign(3,0);  //if you have reached the end of the line then just enter in zero for all the numbers
                            break;
                        }
                    }//end of ave WS loop

                    stats.push_back(generator);  //add on WS numbers
                }//enter in all the stats for loop

                //enter in the stats for the class
                class_stats.push_back(stats);
            }
        }
        INQchar_file.close();






    }

    QStringList qsl, qsl_2;
    qsl   << "" << "L" << "H" << "S" << "A" << "C";
    qsl_2 << "" << "L" << "H" <<        "A" << "C";

    ui_Head_combo->addItems(qsl_2);
    ui_Chest_combo->addItems(qsl);
    ui_Abdomen_combo->addItems(qsl);
    ui_RArm_combo->addItems(qsl);
    ui_LArm_combo->addItems(qsl);
    ui_Groin_combo->addItems(qsl_2);
    ui_RLeg_combo->addItems(qsl);
    ui_LLeg_combo->addItems(qsl);

    ui_Head_spin->setValue(0);
    ui_Chest_spin->setValue(0);
    ui_Abdomen_spin->setValue(0);
    ui_RArm_spin->setValue(0);
    ui_LArm_spin->setValue(0);
    ui_Groin_spin->setValue(0);
    ui_RLeg_spin->setValue(0);
    ui_LLeg_spin->setValue(0);

    QString qs;
    for(unsigned int i = 0; i < class_names.size(); i++)
    {
        qs = class_names.at(i).c_str();

        ui_SelectClass->addItem(qs);
    }


}

void BasicINQ::on_Generate_button_clicked()
{
    int index = ui_SelectClass->currentIndex();
    int stat;
    QString qs;

    //set WS
    stat = class_stats.at(index).at(WS).at(AVE);    //set the base average

    for(int i = 0; i < class_stats.at(index).at(WS).at(DICE_NUM); i++)
    {
        stat += rand()%class_stats.at(index).at(WS).at(DICE_TYPE)+1;
    }

    qs.setNum(stat);
    ui_WS_box->setText(qs);

    //set BS
    stat = class_stats.at(index).at(BS).at(AVE);    //set the base average

    for(int i = 0; i < class_stats.at(index).at(BS).at(DICE_NUM); i++)
    {
        stat += rand()%class_stats.at(index).at(BS).at(DICE_TYPE)+1;
    }

    qs.setNum(stat);
    ui_BS_box->setText(qs);

    //set S
    stat = class_stats.at(index).at(S).at(AVE);    //set the base average

    for(int i = 0; i < class_stats.at(index).at(S).at(DICE_NUM); i++)
    {
        stat += rand()%class_stats.at(index).at(S).at(DICE_TYPE)+1;
    }

    qs.setNum(stat);
    ui_S_box->setText(qs);

    //set T
    stat = class_stats.at(index).at(T).at(AVE);    //set the base average

    for(int i = 0; i < class_stats.at(index).at(T).at(DICE_NUM); i++)
    {
        stat += rand()%class_stats.at(index).at(T).at(DICE_TYPE)+1;
    }

    qs.setNum(stat);
    ui_T_box->setText(qs);

    //set I
    stat = class_stats.at(index).at(I).at(AVE);    //set the base average

    for(int i = 0; i < class_stats.at(index).at(I).at(DICE_NUM); i++)
    {
        stat += rand()%class_stats.at(index).at(I).at(DICE_TYPE)+1;
    }

    qs.setNum(stat);
    ui_I_box->setText(qs);

    //set Wp
    stat = class_stats.at(index).at(Wp).at(AVE);    //set the base average

    for(int i = 0; i < class_stats.at(index).at(Wp).at(DICE_NUM); i++)
    {
        stat += rand()%class_stats.at(index).at(Wp).at(DICE_TYPE)+1;
    }

    qs.setNum(stat);
    ui_Wp_box->setText(qs);

    //set Sg
    stat = class_stats.at(index).at(Sg).at(AVE);    //set the base average

    for(int i = 0; i < class_stats.at(index).at(Sg).at(DICE_NUM); i++)
    {
        stat += rand()%class_stats.at(index).at(Sg).at(DICE_TYPE)+1;
    }

    qs.setNum(stat);
    ui_Sg_box->setText(qs);

    //set Nv
    stat = class_stats.at(index).at(Nv).at(AVE);    //set the base average

    for(int i = 0; i < class_stats.at(index).at(Nv).at(DICE_NUM); i++)
    {
        stat += rand()%class_stats.at(index).at(Nv).at(DICE_TYPE)+1;
    }

    qs.setNum(stat);
    ui_Nv_box->setText(qs);

    //set Ld
    stat = class_stats.at(index).at(Ld).at(AVE);    //set the base average

    for(int i = 0; i < class_stats.at(index).at(Ld).at(DICE_NUM); i++)
    {
        stat += rand()%class_stats.at(index).at(Ld).at(DICE_TYPE)+1;
    }

    qs.setNum(stat);
    ui_Ld_box->setText(qs);

    qs = ui_I_box->text();
    stat = (qs.toInt()+10)/20+1;
    qs.setNum(stat);
    ui_Speed_box->setText(qs);


}

void BasicINQ::on_Create_button_clicked()
{
    vector<int> stats;
    vector<bool> bool_vec;

    bool ok;
    QString name = QInputDialog::getText(this, tr("Input Character Name"), tr("Character name:"), QLineEdit::Normal,QString::null, &ok );

    if( ok && !name.isEmpty() )
    {
        //create stats
        stats.push_back(ui_WS_box->text().toInt());
        stats.push_back(ui_BS_box->text().toInt());
        stats.push_back(ui_S_box->text().toInt());
        stats.push_back(ui_T_box->text().toInt());
        stats.push_back(ui_I_box->text().toInt());
        stats.push_back(ui_Wp_box->text().toInt());
        stats.push_back(ui_Sg_box->text().toInt());
        stats.push_back(ui_Nv_box->text().toInt());
        stats.push_back(ui_Ld_box->text().toInt());
        stats.push_back(ui_Speed_box->text().toInt());


        char_stats.push_back(stats);

        //initialize character armour, IV, and IT
        stats.clear();
        stats.assign(8,0);        
        char_armour.push_back(stats);
        char_IV.push_back(stats);
        heal_count.push_back(stats);

        stats.clear();
        stats.assign(2,0);
        char_parry.push_back(stats);

        char_IT.push_back(0);
        char_stun.push_back(0);
        char_KB.push_back(0);

        bool_vec.clear();
        bool_vec.assign(8,false);
        char_bleed.push_back(bool_vec);

        bool_vec.clear();
        bool_vec.assign(5,false);
        char_status.push_back(bool_vec);

        char_speedLoss.push_back(0);

        bool_vec.assign(8,false);
        armour_damage.push_back(bool_vec);

        //create character name
        char_names.push_back(name.toStdString());

        ui_SelectChar->addItem(name);

    }
}

void BasicINQ::on_SelectChar_currentIndexChanged(int index)
{

    vector<int> stats;
    vector<bool> bool_vec;

    if(char_index >= 0 && char_index < (int)char_stats.size())
    {

        //save character stats
        stats.push_back(ui_WS_box_2->text().toInt());
        stats.push_back(ui_BS_box_2->text().toInt());
        stats.push_back(ui_S_box_2->text().toInt());
        stats.push_back(ui_T_box_2->text().toInt());
        stats.push_back(ui_I_box_2->text().toInt());
        stats.push_back(ui_Wp_box_2->text().toInt());
        stats.push_back(ui_Sg_box_2->text().toInt());
        stats.push_back(ui_Nv_box_2->text().toInt());
        stats.push_back(ui_Ld_box_2->text().toInt());
        stats.push_back(  (ui_I_box_2->text().toInt()+10)/20 +1  );

        char_stats.at(char_index) = stats;

        //save character armour
        stats.clear();

        stats.push_back(ui_Head_spin->value());
        stats.push_back(ui_Chest_spin->value());
        stats.push_back(ui_Abdomen_spin->value());
        stats.push_back(ui_RArm_spin->value());
        stats.push_back(ui_LArm_spin->value());
        stats.push_back(ui_Groin_spin->value());
        stats.push_back(ui_RLeg_spin->value());
        stats.push_back(ui_LLeg_spin->value());

        char_armour.at(char_index) = stats;

        //save character IV
        stats.clear();

        stats.push_back(ui_Head_combo->currentIndex());
        stats.push_back(ui_Chest_combo->currentIndex());
        stats.push_back(ui_Abdomen_combo->currentIndex());
        stats.push_back(ui_RArm_combo->currentIndex());
        stats.push_back(ui_LArm_combo->currentIndex());
        stats.push_back(ui_Groin_combo->currentIndex());
        stats.push_back(ui_RLeg_combo->currentIndex());
        stats.push_back(ui_LLeg_combo->currentIndex());

        char_IV.at(char_index) = stats;

        //save character bleeding status
        bool_vec.push_back(ui_Head_check->isChecked() );
        bool_vec.push_back(ui_Chest_check->isChecked() );
        bool_vec.push_back(ui_Abdomen_check->isChecked() );
        bool_vec.push_back(ui_RArm_check->isChecked() );
        bool_vec.push_back(ui_LArm_check->isChecked() );
        bool_vec.push_back(ui_Groin_check->isChecked() );
        bool_vec.push_back(ui_RLeg_check->isChecked() );
        bool_vec.push_back(ui_LLeg_check->isChecked() );

        char_bleed.at(char_index) = bool_vec;

        //save character overall status
        bool_vec.clear();

        bool_vec.push_back(ui_Prone_check->isChecked());
        bool_vec.push_back(ui_SS_check->isChecked());
        bool_vec.push_back(ui_KO_check->isChecked());
        bool_vec.push_back(ui_Dead_check->isChecked());

        char_status.at(char_index) = bool_vec;

        //save character stun state
        char_stun.at(char_index) = ui_Stun_spin->value();

        //save character KB distance
        char_KB.at(char_index) = ui_KB_spin->value();

        //save character IT
        char_IT.at(char_index) = ui_IT_spin->value();

        //save character parries
        char_parry.at(char_index).at(RIGHT) = ui_RParry_spin->value();
        char_parry.at(char_index).at(LEFT)  = ui_LParry_spin->value();


    }

    if(index >= 0 && index < (int)char_stats.size())
    {

        QString qs;

        //load the character's stats
        qs.setNum(char_stats.at(index).at(WS));
        ui_WS_box_2->setText(qs);
        qs.setNum(char_stats.at(index).at(BS));
        ui_BS_box_2->setText(qs);
        qs.setNum(char_stats.at(index).at(S));
        ui_S_box_2->setText(qs);

        qs.setNum(char_stats.at(index).at(T));
        ui_T_box_2->setText(qs);
        qs.setNum(char_stats.at(index).at(I));
        ui_I_box_2->setText(qs);
        qs.setNum(char_stats.at(index).at(Wp));
        ui_Wp_box_2->setText(qs);
        qs.setNum(char_stats.at(index).at(Sg));
        ui_Sg_box_2->setText(qs);
        qs.setNum(char_stats.at(index).at(Nv));
        ui_Nv_box_2->setText(qs);
        qs.setNum(char_stats.at(index).at(Ld));
        ui_Ld_box_2->setText(qs);
        qs.setNum(  max( char_stats.at(index).at(Speed) - char_speedLoss.at(index),1 )  );
        ui_Speed_box_2->setText(qs);


        //load the character's armour
        char_armour.at(index).at(HEAD);


        ui_Head_spin->setValue(char_armour.at(index).at(HEAD));
        ui_Chest_spin->setValue(char_armour.at(index).at(CHEST));
        ui_Abdomen_spin->setValue(char_armour.at(index).at(ABDOMEN));
        ui_RArm_spin->setValue(char_armour.at(index).at(RARM));
        ui_LArm_spin->setValue(char_armour.at(index).at(LARM));
        ui_Groin_spin->setValue(char_armour.at(index).at(GROIN));
        ui_RLeg_spin->setValue(char_armour.at(index).at(RLEG));
        ui_LLeg_spin->setValue(char_armour.at(index).at(LLEG));

        //load the character's IV
        ui_Head_combo->setCurrentIndex(char_IV.at(index).at(HEAD));
        ui_Chest_combo->setCurrentIndex(char_IV.at(index).at(CHEST));
        ui_Abdomen_combo->setCurrentIndex(char_IV.at(index).at(ABDOMEN));
        ui_RArm_combo->setCurrentIndex(char_IV.at(index).at(RARM));
        ui_LArm_combo->setCurrentIndex(char_IV.at(index).at(LARM));
        ui_Groin_combo->setCurrentIndex(char_IV.at(index).at(GROIN));
        ui_RLeg_combo->setCurrentIndex(char_IV.at(index).at(RLEG));
        ui_LLeg_combo->setCurrentIndex(char_IV.at(index).at(LLEG));

        //load the character's bleeding state
        ui_Head_check->setChecked(char_bleed.at(index).at(HEAD));
        ui_Chest_check->setChecked(char_bleed.at(index).at(CHEST));
        ui_Abdomen_check->setChecked(char_bleed.at(index).at(ABDOMEN));
        ui_RArm_check->setChecked(char_bleed.at(index).at(RARM));
        ui_LArm_check->setChecked(char_bleed.at(index).at(LARM));
        ui_Groin_check->setChecked(char_bleed.at(index).at(GROIN));
        ui_RLeg_check->setChecked(char_bleed.at(index).at(RLEG));
        ui_LLeg_check->setChecked(char_bleed.at(index).at(LLEG));

        //load the character's current status
        ui_Prone_check->setChecked(char_status.at(index).at(PRONE));

        ui_SS_check->setChecked(char_status.at(index).at(SS));
        ui_KO_check->setChecked(char_status.at(index).at(KO));
        ui_Dead_check->setChecked(char_status.at(index).at(DEAD));

        //load the character's IT
        ui_IT_spin->setValue(char_IT.at(index));

        //load the character's KB distance
        ui_KB_spin->setValue(char_KB.at(index));

        //load the character's stuned state
        ui_Stun_spin->setValue(char_stun.at(index));

        //load the character's parries
        ui_RParry_spin->setValue(char_parry.at(index).at(RIGHT) );
        ui_LParry_spin->setValue(char_parry.at(index).at(LEFT)  );

    }

    char_index = index;

    Notes();


}

void BasicINQ::on_Turn_button_clicked()
{
    int D100;
    QString qs;

    //add one to the turn counter
    ui_Turn_spin->setValue(ui_Turn_spin->value() +1);

    //make sure we atleast have a character made
    if(char_index != -1)
    {

        //cycle through every character
        for(unsigned int index = 0; index < char_names.size(); index++)
        {
            //roll a D100 to see if they heal
            D100 = rand()%100+1;

            //don't use the saved data for the current character as they most likey have nopt been saved recently
            if(index != (unsigned int)char_index)
            {
                if(char_status.at(index).at(KO) == false && char_status.at(index).at(DEAD) == false)
                {
                    //did they pass their toughness test to heal? (96+ auto fail, 5- auto pass)
                    if(D100 < 96 && (D100 <= 5 || D100 <= char_stats.at(index).at(T) ))
                    {
                        char_IT.at(index) = max(char_IT.at(index) - (rand()%3+1) - max((char_stats.at(index).at(T)+5)/10 -5,0),0);

                    }
                }

                //for every location
                for(int i = 0; i < 8; i++)
                {
                    //that is bleeding
                    if(  char_bleed.at(index).at(i)  )
                    {
                        //add D3 to their injury total
                        char_IT.at(index) += rand()%3  +1;
                    }
                }

                //decrease the stun counter to a minimum of zero
                char_stun.at(index) = max(char_stun.at(index) -1, 0);

                //reset the parry counters
                char_parry.at(index).at(RIGHT) = 0;
                char_parry.at(index).at(LEFT)  = 0;
            }
            else
            {
                if(ui_KO_check->isChecked() == false && ui_Dead_check->isChecked() == false)
                {
                    //did they pass their toughness test? (96+ auto fail, 5- auto pass)
                    if(D100 < 96 && (D100 <= 5 || D100 <= ui_T_box_2->text().toInt() ))
                    {
                        ui_IT_spin->setValue(  max(ui_IT_spin->value() - (rand()%3+1) - max( (ui_T_box_2->text().toInt()+5)/10 -5,0) ,0)  );

                    }
                }


                //decrease the stun counter to a minimum of zero
                ui_Stun_spin->setValue( max(ui_Stun_spin->value() -1, 0) );

                //reset the parry counters
                ui_RParry_spin->setValue(0);
                ui_LParry_spin->setValue(0);
            }
        }

    }
}

void BasicINQ::on_Dodge_button_clicked()
{
    int Greater_Parry;

    Greater_Parry = max(ui_RParry_spin->value(),ui_LParry_spin->value());

    ui_RParry_spin->setValue(Greater_Parry +1);
    ui_LParry_spin->setValue(Greater_Parry +1);
}

void BasicINQ::on_actionTurnNext_triggered()
{
    on_Turn_button_clicked();
}

void BasicINQ::on_actionResetAll_triggered()
{
    vector<int> int_vec;
    vector<bool> bool_vec1, bool_vec2;
    int temp_index;

    int_vec.assign(8,0);
    bool_vec1.assign(8,false);
    bool_vec2.assign(4,false);

    //set all the temporary stats to 0
    for(unsigned int index = 0; index < char_names.size(); index++)
    {

        char_IV.at(index) = int_vec;

        char_IT.at(index) = 0;

        char_bleed.at(index) = bool_vec1;

        char_status.at(index) = bool_vec2;

        armour_damage.at(index) = bool_vec1;

        char_stun.at(index) = 0;
        char_KB.at(index) = 0;

        heal_count.at(index) = int_vec;

        char_parry.at(index).at(RIGHT) = 0;
        char_parry.at(index).at(LEFT) = 0;
    }

    //load the reset data for the current character
    temp_index = char_index;
    //but don't save the unreset data
    char_index = -1;
    on_SelectChar_currentIndexChanged(temp_index);
}

void BasicINQ::on_actionResetCurrent_triggered()
{
    ui_Head_combo->setCurrentIndex(0);
    ui_Chest_combo->setCurrentIndex(0);
    ui_Abdomen_combo->setCurrentIndex(0);
    ui_RArm_combo->setCurrentIndex(0);
    ui_LArm_combo->setCurrentIndex(0);
    ui_Groin_combo->setCurrentIndex(0);
    ui_RLeg_combo->setCurrentIndex(0);
    ui_LLeg_combo->setCurrentIndex(0);

    ui_IT_spin->setValue(0);

    ui_Head_check->setChecked(false);
    ui_Chest_check->setChecked(false);
    ui_Abdomen_check->setChecked(false);
    ui_RArm_check->setChecked(false);
    ui_LArm_check->setChecked(false);
    ui_Groin_check->setChecked(false);
    ui_RLeg_check->setChecked(false);
    ui_LLeg_check->setChecked(false);

    ui_Prone_check->setChecked(false);
    ui_KB_spin->setValue(0);
    ui_SS_check->setChecked(false);
    ui_KO_check->setChecked(false);
    ui_Dead_check->setChecked(false);

    ui_Stun_spin->setValue(0);

    ui_RParry_spin->setValue(0);
    ui_LParry_spin->setValue(0);
}

void BasicINQ::on_actionFileRemoveAll_triggered()
{
    char_names.clear();
    char_stats.clear();
    char_armour.clear();
    char_IV.clear();
    char_IT.clear();
    char_bleed.clear();
    char_status.clear();
    char_stun.clear();
    char_parry.clear();
    char_KB.clear();
    armour_damage.clear();
    heal_count.clear();

    ui_SelectChar->clear();

    ui_Head_spin->setValue(0);
    ui_Chest_spin->setValue(0);
    ui_Abdomen_spin->setValue(0);
    ui_RArm_spin->setValue(0);
    ui_LArm_spin->setValue(0);
    ui_Groin_spin->setValue(0);
    ui_RLeg_spin->setValue(0);
    ui_LLeg_spin->setValue(0);

    ui_WS_box_2->setText("");
    ui_BS_box_2->setText("");
    ui_S_box_2->setText("");
    ui_T_box_2->setText("");
    ui_I_box_2->setText("");
    ui_Wp_box_2->setText("");
    ui_Sg_box_2->setText("");
    ui_Nv_box_2->setText("");
    ui_Ld_box_2->setText("");

    ui_Head_combo->setCurrentIndex(0);
    ui_Chest_combo->setCurrentIndex(0);
    ui_Abdomen_combo->setCurrentIndex(0);
    ui_RArm_combo->setCurrentIndex(0);
    ui_LArm_combo->setCurrentIndex(0);
    ui_Groin_combo->setCurrentIndex(0);
    ui_RLeg_combo->setCurrentIndex(0);
    ui_LLeg_combo->setCurrentIndex(0);

    ui_Head_combo->setCurrentIndex(0);
    ui_Chest_combo->setCurrentIndex(0);
    ui_Abdomen_combo->setCurrentIndex(0);
    ui_RArm_combo->setCurrentIndex(0);
    ui_LArm_combo->setCurrentIndex(0);
    ui_Groin_combo->setCurrentIndex(0);
    ui_RLeg_combo->setCurrentIndex(0);
    ui_LLeg_combo->setCurrentIndex(0);

    ui_IT_spin->setValue(0);

    ui_Head_check->setChecked(false);
    ui_Chest_check->setChecked(false);
    ui_Abdomen_check->setChecked(false);
    ui_RArm_check->setChecked(false);
    ui_LArm_check->setChecked(false);
    ui_Groin_check->setChecked(false);
    ui_RLeg_check->setChecked(false);
    ui_LLeg_check->setChecked(false);

    ui_Prone_check->setChecked(false);
    ui_KB_spin->setValue(0);
    ui_SS_check->setChecked(false);
    ui_KO_check->setChecked(false);
    ui_Dead_check->setChecked(false);

    ui_Stun_spin->setValue(0);

    ui_RParry_spin->setValue(0);
    ui_LParry_spin->setValue(0);

    char_index = -1;
}

void BasicINQ::on_actionFileNew_triggered()
{
    on_actionFileRemoveAll_triggered();

    ui_Turn_spin->setValue(0);
}

void BasicINQ::on_actionFileRemoveCurrent_Character_triggered()
{
    //=====UNDER CONSTRUCTION=====
    /*if(char_index == -1)
    {}
    if(char_names.size() == 1)
    {
        //there is only one character here, and we are removing him, we already have a method for that
        on_actionFileRemoveAll_triggered();
    }
    else if(char_index < (int)char_names.size() -1 )
    {
        //the current character is about to be removed.  Load up the next character on the list
        ui_SelectChar->setCurrentIndex(char_index+1);
        //remove the used to be current character
        ui_SelectChar->removeItem(char_index-1);

        //go through the vectors shifting the right hand data over
        for(int index = char_index; index < (int)char_names.size(); index++)
        {
            char_names.at(index -1) = char_names.at(index);
            char_stats.at(index -1) = char_stats.at(index);
            char_armour.at(index -1)= char_armour.at(index);
            char_IV.at(index -1)    = char_IV.at(index);
            char_IT.at(index -1)    = char_IT.at(index);
            char_bleed.at(index -1) = char_bleed.at(index);
            char_status.at(index -1)= char_status.at(index);
            char_stun.at(index -1)  = char_stun.at(index);
            char_parry.at(index -1) = char_parry.at(index);
        }
        //remove the repeated last element
        char_names.pop_back();
        char_stats.pop_back();
        char_armour.pop_back();
        char_IV.pop_back();
        char_IT.pop_back();
        char_bleed.pop_back();
        char_status.pop_back();
        char_stun.pop_back();
        char_parry.pop_back();

        //adjust the char_index to the current size
        char_index--;
    }
    else
    {
        //the current character is about to be removed.  Load up the previous character on the list
        ui_SelectChar->setCurrentIndex(char_index-1);

        //remove the current character who happens to be the last element in each vector
        char_names.pop_back();
        char_stats.pop_back();
        char_armour.pop_back();
        char_IV.pop_back();
        char_IT.pop_back();
        char_bleed.pop_back();
        char_status.pop_back();
        char_stun.pop_back();
        char_parry.pop_back();

        //adjust the char_index to the current size
        char_index--;
    }*/
}

void BasicINQ::on_Injur_button_clicked()
{
    int KB;
    int Dam, Dam2,temp_Dam;


    //define Dam and Dam2
    Dam = Dam2 = ui_Injur_spin->value();
    //reset Injur_spin to let user know the character was indeed damaged
    ui_Injur_spin->setValue(0);



    if(ui_Location_radio->isChecked())
    {
        ui_Location_radio->setChecked(false);

        if(ui_Location_spin->value() < 31)
        {
            //The Legs
            if(rand()%2)
            {
                //Right Leg
                ui_RLeg_radio->setChecked(true);
            }
            else
            {
                //Left Leg
                ui_LLeg_radio->setChecked(true);
            }
        }
        else if(ui_Location_spin->value() < 36)
        {
            //The Groin
            ui_Groin_radio->setChecked(true);
        }
        else if(ui_Location_spin->value() < 66)
        {
            //The Arms
            if(rand()%2)
            {
                //Right Arm
                ui_RArm_radio->setChecked(true);
            }
            else
            {
                //Left Arm
                ui_LArm_radio->setChecked(true);
            }
        }
        else if(ui_Location_spin->value() < 81)
        {
            //The Abdomen
            ui_Abdomen_radio->setChecked(true);
        }
        else if(ui_Location_spin->value() < 96)
        {
            //The Chest
            ui_Chest_radio->setChecked(true);
        }
        else
        {
            //The Head
            ui_Head_radio->setChecked(true);
        }
    }

    //define the KB value
    KB = max((ui_S_box_2->text().toInt()+5)/10 , 1);

    //did you get Knocked over and/or Knocked back?
    if(Dam > KB)
    {
        //Get Knocked Back
        if( !(ui_LLeg_radio->isChecked() || ui_RLeg_radio->isChecked()) )
        {
            ui_KB_spin->setValue(ui_KB_spin->value()+max(Dam-1,0)/KB );

        }

        //Get Knocked over
        if(Dam > 2*KB)
            ui_Prone_check->setChecked(true);
    }

    //Injur the Head
    if(ui_Head_radio->isChecked())
    {
        Dam = max(Dam- ui_Head_spin->value() , 0);
        temp_Dam = Dam;

        while(temp_Dam > 0 && ui_Head_combo->currentIndex() < 4)
        {
            ui_Head_combo->setCurrentIndex(ui_Head_combo->currentIndex()+1);
            Damage(HEAD,ui_Head_combo->currentIndex(),true);
            temp_Dam -= (ui_T_box_2->text().toInt()+5)/10;
        }

        //Damage Armour
        if(Dam2 > 2*ui_Head_spin->value())
        {
            if(armour_damage.at(char_index).at(HEAD))
            {
                ui_Head_spin->setValue(0);
            }
            else
            {
                armour_damage.at(char_index).at(HEAD) = true;
                ui_Head_spin->setValue((ui_Head_spin->value()+1)/2);
            }
        }
    }//Injur the Chest
    else if(ui_Chest_radio->isChecked())
    {
        Dam= max(Dam- ui_Chest_spin->value() , 0);
        temp_Dam = Dam;

        while(temp_Dam > 0 && ui_Chest_combo->currentIndex() < 5)
        {
            ui_Chest_combo->setCurrentIndex(ui_Chest_combo->currentIndex()+1);
            Damage(CHEST,ui_Chest_combo->currentIndex(),true);
            temp_Dam -= (ui_T_box_2->text().toInt()+5)/10;
        }

        //Damage Armour
        if(Dam2 > 2*ui_Chest_spin->value())
        {
            if(armour_damage.at(char_index).at(CHEST))
            {
                ui_Chest_spin->setValue(0);
            }
            else
            {
                armour_damage.at(char_index).at(CHEST) = true;
                ui_Chest_spin->setValue((ui_Chest_spin->value()+1)/2);
            }
        }
    }//Injur the Abdomen
    else if(ui_Abdomen_radio->isChecked())
    {
        Dam= max(Dam- ui_Abdomen_spin->value() , 0);
        temp_Dam = Dam;

        while(temp_Dam > 0 && ui_Abdomen_combo->currentIndex() < 5)
        {
            ui_Abdomen_combo->setCurrentIndex(ui_Abdomen_combo->currentIndex()+1);
            Damage(ABDOMEN,ui_Abdomen_combo->currentIndex(),true);
            temp_Dam -= (ui_T_box_2->text().toInt()+5)/10;
        }

        //Damage Armour
        if(Dam2 > 2*ui_Abdomen_spin->value())
        {
            if(armour_damage.at(char_index).at(ABDOMEN))
            {
                ui_Abdomen_spin->setValue(0);
            }
            else
            {
                armour_damage.at(char_index).at(ABDOMEN) = true;
                ui_Abdomen_spin->setValue((ui_Abdomen_spin->value()+1)/2);
            }
        }
    }//Injur the RArm
    else if(ui_RArm_radio->isChecked())
    {
        Dam = max(Dam- ui_RArm_spin->value() , 0);
        temp_Dam = Dam;

        while(temp_Dam > 0 && ui_RArm_combo->currentIndex() < 5)
        {
            ui_RArm_combo->setCurrentIndex(ui_RArm_combo->currentIndex()+1);
            Damage(RARM,ui_RArm_combo->currentIndex(),true);
            temp_Dam -= (ui_T_box_2->text().toInt()+5)/10;
        }

        //Damage Armour
        if(Dam2 > 2*ui_RArm_spin->value())
        {
            if(armour_damage.at(char_index).at(RARM))
            {
                ui_RArm_spin->setValue(0);
            }
            else
            {
                armour_damage.at(char_index).at(RARM) = true;
                ui_RArm_spin->setValue((ui_RArm_spin->value()+1)/2);
            }
        }
    }//Injur the LArm
    else if(ui_LArm_radio->isChecked())
    {
        Dam= max(Dam- ui_LArm_spin->value() , 0);
        temp_Dam = Dam;

        while(temp_Dam > 0 && ui_LArm_combo->currentIndex() < 5)
        {
            ui_LArm_combo->setCurrentIndex(ui_LArm_combo->currentIndex()+1);
            Damage(LARM,ui_LArm_combo->currentIndex(),true);
            temp_Dam -= (ui_T_box_2->text().toInt()+5)/10;
        }

        //Damage Armour
        if(Dam2 > 2*ui_LArm_spin->value())
        {
            if(armour_damage.at(char_index).at(LARM))
            {
                ui_LArm_spin->setValue(0);
            }
            else
            {
                armour_damage.at(char_index).at(LARM) = true;
                ui_LArm_spin->setValue((ui_LArm_spin->value()+1)/2);
            }
        }
    }//Injur the Groin
    else if(ui_Groin_radio->isChecked())
    {
        Dam= max(Dam- ui_Groin_spin->value() , 0);
        temp_Dam = Dam;

        while(temp_Dam > 0 && ui_Groin_combo->currentIndex() < 4)
        {
            ui_Groin_combo->setCurrentIndex(ui_Groin_combo->currentIndex()+1);
            Damage(GROIN,ui_Groin_combo->currentIndex(),true);
            temp_Dam -= (ui_T_box_2->text().toInt()+5)/10;
        }

        //Damage Armour
        if(Dam2 > 2*ui_Groin_spin->value())
        {
            if(armour_damage.at(char_index).at(GROIN))
            {
                ui_Groin_spin->setValue(0);
            }
            else
            {
                armour_damage.at(char_index).at(GROIN) = true;
                ui_Groin_spin->setValue((ui_Groin_spin->value()+1)/2);
            }
        }
    }//Injur the RLeg
    else if(ui_RLeg_radio->isChecked())
    {
        Dam= max(Dam- ui_RLeg_spin->value() , 0);
        temp_Dam = Dam;

        while(temp_Dam > 0 && ui_RLeg_combo->currentIndex() < 5)
        {
            ui_RLeg_combo->setCurrentIndex(ui_RLeg_combo->currentIndex()+1);
            Damage(RLEG,ui_RLeg_combo->currentIndex(),true);
            temp_Dam -= (ui_T_box_2->text().toInt()+5)/10;
        }

        //Damage Armour
        if(Dam2 > 2*ui_RLeg_spin->value())
        {
            if(armour_damage.at(char_index).at(RLEG))
            {
                ui_RLeg_spin->setValue(0);
            }
            else
            {
                armour_damage.at(char_index).at(RLEG) = true;
                ui_RLeg_spin->setValue((ui_RLeg_spin->value()+1)/2);
            }
        }
    }//Injur the LLeg
    else if(ui_LLeg_radio->isChecked())
    {
        Dam= max(Dam- ui_LLeg_spin->value() , 0);
        temp_Dam = Dam;

        while(temp_Dam > 0 && ui_LLeg_combo->currentIndex() < 5)
        {
            ui_LLeg_combo->setCurrentIndex(ui_LLeg_combo->currentIndex()+1);
            Damage(LLEG,ui_LLeg_combo->currentIndex(),true);
            temp_Dam -= (ui_T_box_2->text().toInt()+5)/10;
        }

        //Damage Armour
        if(Dam2 > 2*ui_LLeg_spin->value())
        {
            if(armour_damage.at(char_index).at(LLEG))
            {
                ui_LLeg_spin->setValue(0);
            }
            else
            {
                armour_damage.at(char_index).at(LLEG) = true;
                ui_LLeg_spin->setValue((ui_LLeg_spin->value()+1)/2);
            }
        }
    }

    //add up Injury Total
    ui_IT_spin->setValue(ui_IT_spin->value() + Dam);

    //did this blow make the character pass out?
    //Take a T test if the blow was powerful enough
    if(Dam >= (ui_T_box_2->text().toInt()+2)/5 && (rand()%100 +1) > min(max(ui_T_box_2->text().toInt(),95),5) )
        ui_KO_check->setChecked(true);




    //Has the IT caused the character to pass out?
    if(ui_IT_spin->value() >= (ui_T_box_2->text().toInt()+1)/2)
        ui_KO_check->setChecked(true);

    //Has the IT casued the character to just plain die
    if(ui_IT_spin->value() >= ui_T_box_2->text().toInt() )
        ui_Dead_check->setChecked(true);


}

void BasicINQ::on_Heal_button_clicked()
{
    if(ui_Location_radio->isChecked())
    {
        ui_Location_radio->setChecked(false);

        if(ui_Location_spin->value() < 31)
        {
            //The Legs
            if(rand()%2)
            {
                //Right Leg
                ui_RLeg_radio->setChecked(true);
            }
            else
            {
                //Left Leg
                ui_LLeg_radio->setChecked(true);
            }
        }
        else if(ui_Location_spin->value() < 36)
        {
            //The Groin
            ui_Groin_radio->setChecked(true);
        }
        else if(ui_Location_spin->value() < 66)
        {
            //The Arms
            if(rand()%2)
            {
                //Right Arm
                ui_RArm_radio->setChecked(true);
            }
            else
            {
                //Left Arm
                ui_LArm_radio->setChecked(true);
            }
        }
        else if(ui_Location_spin->value() < 81)
        {
            //The Abdomen
            ui_Abdomen_radio->setChecked(true);
        }
        else if(ui_Location_spin->value() < 96)
        {
            //The Chest
            ui_Chest_radio->setChecked(true);
        }
        else
        {
            //The Head
            ui_Head_radio->setChecked(true);
        }
    }

    if(ui_Head_radio->isChecked())
    {
        if(ui_Head_combo->currentIndex() != 0)
        {
            ui_Head_combo->setCurrentIndex(ui_Head_combo->currentIndex()-1);
            Damage(HEAD,ui_Head_combo->currentIndex(),false);

            heal_count.at(char_index).at(HEAD)++;
        }
    }
    else if(ui_Chest_radio->isChecked())
    {
        if(ui_Chest_combo->currentIndex() != 0)
        {
            ui_Chest_combo->setCurrentIndex(ui_Chest_combo->currentIndex()-1);
            Damage(CHEST,ui_Chest_combo->currentIndex(),false);

            heal_count.at(char_index).at(CHEST)++;
        }


    }
    else if(ui_Abdomen_radio->isChecked())
    {
        if(ui_Abdomen_combo->currentIndex() != 0)
        {
            ui_Abdomen_combo->setCurrentIndex(ui_Abdomen_combo->currentIndex()-1);
            Damage(ABDOMEN,ui_Abdomen_combo->currentIndex(),false);

            heal_count.at(char_index).at(ABDOMEN)++;
        }


    }
    else if(ui_RArm_radio->isChecked())
    {
        if(ui_RArm_combo->currentIndex() != 0)
        {
            ui_RArm_combo->setCurrentIndex(ui_RArm_combo->currentIndex()-1);
            Damage(RARM,ui_RArm_combo->currentIndex(),false);

            heal_count.at(char_index).at(RARM)++;
        }


    }
    else if(ui_LArm_radio->isChecked())
    {
        if(ui_LArm_combo->currentIndex() != 0)
        {
            ui_LArm_combo->setCurrentIndex(ui_LArm_combo->currentIndex()-1);
            Damage(LARM,ui_LArm_combo->currentIndex(),false);

            heal_count.at(char_index).at(LARM)++;
        }


    }
    else if(ui_Groin_radio->isChecked())
    {
        if(ui_Groin_combo->currentIndex() != 0)
        {
            ui_Groin_combo->setCurrentIndex(ui_Groin_combo->currentIndex()-1);
            Damage(GROIN,ui_Groin_combo->currentIndex(),false);

            heal_count.at(char_index).at(GROIN)++;
        }


    }
    else if(ui_RLeg_radio->isChecked())
    {
        if(ui_RLeg_combo->currentIndex() != 0)
        {
            ui_RLeg_combo->setCurrentIndex(ui_RLeg_combo->currentIndex()-1);
            Damage(RLEG,ui_RLeg_combo->currentIndex(),false);

            heal_count.at(char_index).at(RLEG)++;
        }


    }
    else if(ui_LLeg_radio->isChecked())
    {
        if(ui_LLeg_combo->currentIndex() != 0)
        {
            ui_LLeg_combo->setCurrentIndex(ui_LLeg_combo->currentIndex()-1);
            Damage(LLEG,ui_LLeg_combo->currentIndex(),false);

            heal_count.at(char_index).at(LLEG)++;
        }


    }

    ui_IT_spin->setValue(  max(ui_IT_spin->value() - (rand()%3+1) - ((ui_T_box_2->text().toInt()+5)/10 -5),0)  );

    HealNotes();
}

void BasicINQ::Damage(int location, int level, bool Injur)
{
    QString qs;

    switch(location) {
        case HEAD:  //Head
            switch(level) {
                case 1://L
                    if(Injur)
                    {
                        //Immediate
                            //Character stunned for D3 turns
                        ui_Stun_spin->setValue( ui_Stun_spin->value() + (rand()%3 +1));
                        //Persistent
                            //nothing
                    }
                    else
                    {
                        //Cure the Persistent Effect
                            //Character used to be at -1 Speed
                        char_speedLoss.at(char_index)--;
                            //Don't give them extra speed
                        ui_Speed_box_2->setText(  qs.setNum(min( ui_Speed_box_2->text().toInt()+1,(ui_I_box_2->text().toInt()+10)/20+1 ) ) );
                    }
                    break;

                case 2://H
                    if(Injur)
                    {
                        //Immediate
                            //Character stunned for D3 turns
                        ui_Stun_spin->setValue(  ui_Stun_spin->value() + (rand()%3 +1));
                            //add D6 to Injury Total
                        ui_IT_spin->setValue(  ui_IT_spin->value() + (rand()%6+1));
                        //Persistent
                            //Character at -1 Speed
                        char_speedLoss.at(char_index)++;
                            //Don't let their speed go below 1
                        ui_Speed_box_2->setText(qs.setNum(max(ui_Speed_box_2->text().toInt()-1,1)));

                    }/*
                    else
                    {
                        //Can't heal KO
                    }*/
                    break;

                case 3://A
                    if(Injur)
                    {
                        //Immediate
                            //Character Passes Out
                        ui_KO_check->setChecked(true);
                    }/*
                    else
                    {
                        //Can't fix dead.  No head crab zombies!
                    }*/
                    break;

                case 4://C
                    if(Injur)
                    {
                        //Immediate
                            //Character get's their face kicked in
                        ui_Dead_check->setChecked(true);
                    }
                    break;

                }

            break;

        case CHEST: //Chest
            switch(level) {
                case 1://L
                    if(Injur)
                    {
                        //Immediate
                            //Character falls prone
                        ui_Prone_check->setChecked(true);
                    }
                    else
                    {
                        //Cure the Persistent Effect
                            //Character used to be at -1 Speed
                        char_speedLoss.at(char_index)--;
                            //Don't give them extra speed
                        ui_Speed_box_2->setText(  qs.setNum(min( ui_Speed_box_2->text().toInt()+1,(ui_I_box_2->text().toInt()+10)/20+1 )  ) );
                    }
                    break;

                case 2://H
                    if(Injur)
                    {
                        //Immediate
                            //Character falls prone
                        ui_Prone_check->setChecked(true);
                        //Persistent
                            //Character is at -1 Speed
                        char_speedLoss.at(char_index)++;
                            //Don't let their speed go below 1
                        ui_Speed_box_2->setText(qs.setNum(max(ui_Speed_box_2->text().toInt()-1,1)));
                    }/*
                    else
                    {
                        //Nothing Persistent to heal
                    }*/

                    break;

                case 3://S
                    if(Injur)
                    {
                        //Immediate
                            //Character falls prone
                        ui_Prone_check->setChecked(true);
                            //Character stunned for D3 turns
                        ui_Stun_spin->setValue( ui_Stun_spin->value() + (rand()%3 +1));
                    }
                    else
                    {
                        //Cure Persistent effects
                            //Character is no longer bleeding
                        ui_Chest_check->setChecked(false);
                    }
                    break;

                case 4://A
                    if(Injur)
                    {
                        //Immediate
                            //Character falls prone
                        ui_Prone_check->setChecked(true);
                            //Character stunned for D3 turns
                        ui_Stun_spin->setValue( ui_Stun_spin->value() + (rand()%3 +1) );
                        //Persistent
                            //Character is bleeding
                        ui_Chest_check->setChecked(true);
                    }
                    break;

                case 5://C
                    if(Injur)
                    {
                        //Immediate
                            //Arrg, me heart!
                        ui_KO_check->setChecked(true);
                    }
                    break;

                }

            break;

        case ABDOMEN://Abdomen
            switch(level) {
                case 1://L
                    if(Injur)
                    {
                        //Immediate
                            //+D3 to Injury Total
                        ui_IT_spin->setValue( ui_IT_spin->value() + (rand()%3+1));

                    }
                    else
                    {
                        //Cure the Persistent Effect
                            //Character used to be at -1 Speed
                        char_speedLoss.at(char_index)--;
                            //Don't give them extra speed
                        ui_Speed_box_2->setText(  qs.setNum(min( ui_Speed_box_2->text().toInt()+1,(ui_I_box_2->text().toInt()+10)/20+1 ) ) );
                    }
                    break;

                case 2://H
                    if(Injur)
                    {
                        //Immediate
                            //+D3 to Injury Total
                        ui_IT_spin->setValue( ui_IT_spin->value() + (rand()%3+1) );
                            //falls prone
                        ui_Prone_check->setChecked(true);
                        //Persistent
                            //Character at -1 Speed
                        char_speedLoss.at(char_index)++;
                            //Don't let their speed go below 1
                        ui_Speed_box_2->setText(qs.setNum(max(ui_Speed_box_2->text().toInt()-1,1)));

                    }
                    else
                    {
                        //Cure Persistent Effects
                            //Character is no longer bleedin'
                        ui_Abdomen_check->setChecked(false);
                    }
                    break;

                case 3://S
                    if(Injur)
                    {
                        //Immediate
                            //+D3 to Injury Total
                        ui_IT_spin->setValue( ui_IT_spin->value() + (rand()%3+1));
                            //falls prone
                        ui_Prone_check->setChecked(true);
                        //Persistent
                            //is bleedin'nuts... I mean bleeding
                        ui_Abdomen_check->setChecked(true);

                    }
                    break;

                case 4://A
                    if(Injur)
                    {
                        //Immediate
                            //+D3 to Injury Total
                        ui_IT_spin->setValue( ui_IT_spin->value() + (rand()%3+1));
                            //falls prone
                        ui_Prone_check->setChecked(true);
                            //stun for D3 turns
                        ui_Stun_spin->setValue(  ui_Stun_spin->value() + (rand()%3+1));
                    }
                    break;

                case 5://C
                    if(Injur)
                    {
                        //Immediate
                            //+D3 to Injury Total
                        ui_IT_spin->setValue( ui_IT_spin->value() + (rand()%3+1));
                            //falls prone
                        ui_Prone_check->setChecked(true);
                            //stun for D3 turns
                        ui_Stun_spin->setValue( ui_Stun_spin->value() + (rand()%3+1));
                    }
                    break;

                }

            break;

        case RARM:  //Right Arm
            switch(level) {
                case 2://H
                    if(Injur == false)
                    {
                        //Cure any persistent effects
                            //RArm no longer at half WS, BS, and S
                        HandyNotes();

                    }
                    break;

                case 3://S
                    if(Injur)
                    {
                        //Immeditate
                            //+D3 to Injury Total
                        ui_IT_spin->setValue( ui_IT_spin->value() + (rand()%3 +1));
                        //Persistent
                            //Damage the right hand to half WS/BS/S
                        HandyNotes();




                    }
                    else
                    {
                        //Persistent
                            //yay you are no longer bleeding
                        ui_RArm_check->setChecked(false);
                            //stop being such a failure at handyness
                        HandyNotes();
                    }
                    break;

                case 4://A
                    if(Injur)
                    {
                        //Persistent
                            //is bleedin'nuts... I mean bleeding
                        ui_RArm_check->setChecked(true);
                            //Damage the right hand to half not useable
                        HandyNotes();
                    }

                    break;

                case 5://C
                    if(Injur)
                    {
                        //Immediate
                            //If you're a sissy ya pass out
                        if(rand()%100 +1 > min(95, ui_T_box_2->text().toInt()) )
                        {
                            ui_KO_check->setChecked(true);
                        }
                    }

                    break;

                }

            break;

        case LARM:  //Left Arm
            switch(level) {
                case 2://H
                    if(Injur == false)
                    {
                        //Cure any persistent effects
                            //RArm no longer at half WS, BS, and S
                        HandyNotes();

                    }
                    break;

                case 3://S
                    if(Injur)
                    {
                        //Immeditate
                            //+D3 to Injury Total
                        ui_IT_spin->setValue( ui_IT_spin->value() + (rand()%3 +1));
                        //Persistent
                            //Damage the right hand to half WS/BS/S
                        HandyNotes();




                    }
                    else
                    {
                        //Persistent
                            //yay you are no longer bleeding
                        ui_LArm_check->setChecked(false);
                            //stop being such a failure at handyness
                        HandyNotes();
                    }
                    break;

                case 4://A
                    if(Injur)
                    {
                        //Persistent
                            //is bleedin'nuts... I mean bleeding
                        ui_LArm_check->setChecked(true);
                            //Damage the right hand to half not useable
                        HandyNotes();
                    }

                    break;

                case 5://C
                    if(Injur)
                    {
                        //Immediate
                            //If you're a sissy ya pass out
                        if(rand()%100 +1 > min(95, ui_T_box_2->text().toInt()) )
                        {
                            ui_KO_check->setChecked(true);
                        }
                    }

                    break;
                }

            break;

        case GROIN: //Groin
            switch(level) {
                /*case 0://X

                    break;*/

                case 1://L
                    if(Injur)
                    {
                        //Immediate
                            //oi it hit me in the balls
                        ui_Prone_check->setChecked(true);
                    }
                    else
                    {
                        //Persistent
                            //Character used to be at -1 Speed
                        char_speedLoss.at(char_index)--;
                            //Don't give them extra speed
                        ui_Speed_box_2->setText(  qs.setNum(min( ui_Speed_box_2->text().toInt()+1,(ui_I_box_2->text().toInt()+10)/20+1 )  ));
                    }
                    break;

                case 2://H
                    if(Injur)
                    {
                        //Immediate
                            //oi it hit me in the balls
                        ui_Prone_check->setChecked(true);
                            //Stuned for D3 turns
                        ui_Stun_spin->setValue(ui_Stun_spin->value()+rand()%3+1);

                        //Persistent
                            //Speed -1
                        char_speedLoss.at(char_index)++;
                            //Don't let their speed go below 1
                        ui_Speed_box_2->setText(qs.setNum(max(ui_Speed_box_2->text().toInt()-1,1)));
                    }
                    else
                    {
                        //Persistent
                            //not bleedin'
                        ui_Groin_check->setChecked(false);
                    }
                    break;

                case 3://A
                    if(Injur)
                    {
                        //Immediate
                            //oi it hit me in the balls
                        ui_Prone_check->setChecked(true);
                            //Stuned for D3 turns
                        ui_Stun_spin->setValue(ui_Stun_spin->value()+rand()%3+1);
                            //+D3 to IT
                        ui_IT_spin->setValue(ui_IT_spin->value()+rand()%3 +1);

                        //Persistent
                            //bleedin'
                        ui_Groin_check->setChecked(true);
                    }
                    break;

                case 4://C
                    if(Injur)
                    {
                        //Immediate
                            //KO'ed in the Groin!
                        ui_KO_check->setChecked(true);
                    }
                    break;

            }

            break;

        case RLEG:  //Right Leg
            LegyNotes();
            switch(level) {
                case 1://L
                    if(!Injur)
                    {
                        //Persistent
                            //Character used to be at -1 Speed
                        char_speedLoss.at(char_index)--;
                            //Don't give them extra speed
                        ui_Speed_box_2->setText(  qs.setNum(min( ui_Speed_box_2->text().toInt()+1,(ui_I_box_2->text().toInt()+10)/20+1 )  ));
                    }
                    break;

                case 2://H
                    if(Injur)
                    {
                        //Persistent
                            //Speed -1
                        char_speedLoss.at(char_index)++;
                            //Don't let their speed go below 1
                        ui_Speed_box_2->setText(qs.setNum(max(ui_Speed_box_2->text().toInt()-1,1)));
                    }
                    break;

                case 3://S
                    if(Injur)
                    {
                        //Immediate
                            //oi it hit me in the balls
                        ui_Prone_check->setChecked(true);
                            //+D3 to IT
                        ui_IT_spin->setValue(ui_IT_spin->value()+rand()%3 +1);
                    }
                    else
                    {
                        //Persistent
                            //not bleendin'
                        ui_RLeg_check->setChecked(false);
                    }
                    break;

                case 4://A
                    if(Injur)
                    {
                        //Immediate
                            //oi it hit me in the balls
                        ui_Prone_check->setChecked(true);
                            //+D3 to IT
                        ui_IT_spin->setValue(ui_IT_spin->value()+rand()%3 +1);

                        //Persistent
                            //bleendin'!
                        ui_RLeg_check->setChecked(true);
                    }
                    break;

                case 5://C
                    if(Injur)
                    {
                        //Immediate
                            //KO'ed in the Groin!
                        ui_KO_check->setChecked(true);
                    }
                    break;

                }

            break;

        case LLEG:  //Left Leg
            LegyNotes();
            switch(level) {
                case 1://L
                    if(!Injur)
                    {
                        //Persistent
                            //Character used to be at -1 Speed
                        char_speedLoss.at(char_index)--;
                            //Don't give them extra speed
                        ui_Speed_box_2->setText(  qs.setNum(min( ui_Speed_box_2->text().toInt()+1,(ui_I_box_2->text().toInt()+10)/20+1 ) ) );
                    }
                    break;

                case 2://H
                    if(Injur)
                    {
                        //Persistent
                            //Speed -1
                        char_speedLoss.at(char_index)++;
                            //Don't let their speed go below 1
                        ui_Speed_box_2->setText(qs.setNum(max(ui_Speed_box_2->text().toInt()-1,1)));
                    }
                    break;

                case 3://S
                    if(Injur)
                    {
                        //Immediate
                            //oi it hit me in the balls
                        ui_Prone_check->setChecked(true);
                            //+D3 to IT
                        ui_IT_spin->setValue(ui_IT_spin->value()+rand()%3 +1);
                    }
                    else
                    {
                        //Persistent
                            //not bleendin'
                        ui_LLeg_check->setChecked(false);
                    }
                    break;

                case 4://A
                    if(Injur)
                    {
                        //Immediate
                            //oi it hit me in the balls
                        ui_Prone_check->setChecked(true);
                            //+D3 to IT
                        ui_IT_spin->setValue(ui_IT_spin->value()+rand()%3 +1);

                        //Persistent
                            //bleendin'!
                        ui_LLeg_check->setChecked(true);
                    }
                    break;

                case 5://C
                    if(Injur)
                    {
                        //Immediate
                            //KO'ed in the Groin!
                        ui_KO_check->setChecked(true);
                    }
                    break;

                }


            break;

        }
}

void BasicINQ::HandyNotes()
{
    //Modify the Tooltip for WS/BS/S

    int penalty[6];
    QString qs[6];

    //Right Arm Healed & Left Arm Healed
    if(ui_LArm_combo->currentIndex() < 3 && ui_RArm_combo->currentIndex() < 3)
    {
        penalty[0] = (ui_WS_box_2->text().toInt()+1)/2;
        penalty[1] = (ui_WS_box_2->text().toInt()+2)/4;
        ui_WS_box_2->setToolTip("R:" + ui_WS_box_2->text() + "/" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1])
                                + "\nL:" + ui_WS_box_2->text() + "/" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1]));


        ui_BS_box_2->setToolTip("R:" + ui_BS_box_2->text() + "\nL:" + ui_BS_box_2->text());

        penalty[0] = max(  (ui_S_box_2->text().toInt()+5)/10-5,0);
        penalty[1] = (ui_S_box_2->text().toInt()+1)/2;
        penalty[2] = max(  (penalty[1]+5)/10 - 5,0  );
        ui_S_box_2->setToolTip("R&L:" + ui_S_box_2->text() + "(" + qs[0].setNum(penalty[0]) + ")"
                + "\nR:" + qs[1].setNum(penalty[1]) + "(" + qs[2].setNum(penalty[2]) + ")"
                + "\nL:" + qs[1].setNum(penalty[1]) + "(" + qs[2].setNum(penalty[2]) + ")" );
    }
    //Right Arm Healed & Left Arm Damaged
    else if(ui_RArm_combo->currentIndex() < 3)
    {
        penalty[0] = (ui_WS_box_2->text().toInt()+1)/2;
        penalty[1] = (ui_WS_box_2->text().toInt()+2)/4;
        penalty[2] = (ui_WS_box_2->text().toInt()+4)/8;
        //Left Arm Still Useable
        if(ui_LArm_combo->currentIndex() == 3)
        {
            ui_WS_box_2->setToolTip("R:" + ui_WS_box_2->text() + "/" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1])
                                    + "\nL:" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1]) + "/" + qs[2].setNum(penalty[2]));
        }
        else
        {
            ui_WS_box_2->setToolTip("R:" + ui_WS_box_2->text() + "/" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1])
                                    + "\nL:X/X/X");
        }

        penalty[0] = (ui_BS_box_2->text().toInt()+1)/2;
        //Left Arm Still Useable
        if(ui_LArm_combo->currentIndex() == 3)
        {
            ui_BS_box_2->setToolTip("R:" + ui_BS_box_2->text() + "\nL:" + qs[0].setNum(penalty[0]));
        }
        else
        {
            ui_BS_box_2->setToolTip("R:" + ui_BS_box_2->text() + "\nL:X");
        }


        penalty[0] = (ui_S_box_2->text().toInt()+2)*3/4;
        penalty[1] = max(  (penalty[0]+5)/10-5,0);
        penalty[2] = (ui_S_box_2->text().toInt()+1)/2;
        penalty[3] = max(  (penalty[2]+5)/10 - 5,0  );
        penalty[4] = (ui_S_box_2->text().toInt()+2)/4;
        penalty[5] = max(  (penalty[4]+5)/10 - 5,0  );
        //Left Arm Still Useable
        if(ui_LArm_combo->currentIndex() == 3)
        {
            ui_S_box_2->setToolTip("R&L:" + qs[0].setNum(penalty[0]) + "(" + qs[1].setNum(penalty[1]) + ")"
                + "\nR:" + qs[2].setNum(penalty[2]) + "(" + qs[3].setNum(penalty[3]) + ")"
                + "\nL:" + qs[4].setNum(penalty[4]) + "(" + qs[4].setNum(penalty[5]) + ")" );
        }
        else
        {
            ui_S_box_2->setToolTip("R&L:X(X)\nR:" + qs[2].setNum(penalty[2]) + "(" + qs[3].setNum(penalty[3]) + ")"
                + "\nL:X(X)" );
        }

    }
    //Right Arm Damaged & Left Arm Healed
    else if(ui_LArm_combo->currentIndex() < 3)
    {
        penalty[0] = (ui_WS_box_2->text().toInt()+1)/2;
        penalty[1] = (ui_WS_box_2->text().toInt()+2)/4;
        penalty[2] = (ui_WS_box_2->text().toInt()+4)/8;
        //Right Arm Still Useable
        if(ui_RArm_combo->currentIndex() == 3)
        {
            ui_WS_box_2->setToolTip("R:" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1]) + "/" + qs[2].setNum(penalty[2])
                                    + "\nL:" + ui_WS_box_2->text() + "/" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1]));
        }
        else
        {
            ui_WS_box_2->setToolTip("R:X/X/X\nL:" + ui_WS_box_2->text() + "/" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1]));
        }


        penalty[0] = (ui_BS_box_2->text().toInt()+1)/2;
        //Right Arm Still Useable
        if(ui_RArm_combo->currentIndex() == 3)
        {
            ui_BS_box_2->setToolTip("R:" + qs[0].setNum(penalty[0]) + "\nL:" + ui_BS_box_2->text());
        }
        else
        {
            ui_BS_box_2->setToolTip("R:X\nL:" + ui_BS_box_2->text());
        }


        penalty[0] = (ui_S_box_2->text().toInt()+2)*3/4;
        penalty[1] = max(  (penalty[0]+5)/10-5,0);
        penalty[2] = (ui_S_box_2->text().toInt()+1)/2;
        penalty[3] = max(  (penalty[2]+5)/10 - 5,0  );
        penalty[4] = (ui_S_box_2->text().toInt()+2)/4;
        penalty[5] = max(  (penalty[4]+5)/10 - 5,0  );        
        //Left Arm Still Useable
        if(ui_RArm_combo->currentIndex() == 3)
        {
            ui_S_box_2->setToolTip("R&L:" + qs[0].setNum(penalty[0]) + "(" + qs[1].setNum(penalty[1]) + ")"
                    + "\nR:" + qs[4].setNum(penalty[4]) + "(" + qs[4].setNum(penalty[5]) + ")"
                    + "\nL:" + qs[2].setNum(penalty[2]) + "(" + qs[3].setNum(penalty[3]) + ")" );
        }
        else
        {
            ui_S_box_2->setToolTip("R&L:X(X)\nR:X(X)\nL:" + qs[2].setNum(penalty[2]) + "(" + qs[3].setNum(penalty[3]) + ")" );
        }
    }
    //Right Arm Damaged & Left Arm Damaged
    else
    {
        penalty[0] = (ui_WS_box_2->text().toInt()+1)/2;
        penalty[1] = (ui_WS_box_2->text().toInt()+2)/4;
        penalty[2] = (ui_WS_box_2->text().toInt()+4)/8;
        //Both arms still useable
        if(ui_RArm_combo->currentIndex() == 3 && ui_LArm_combo->currentIndex() == 3)
        {
            ui_WS_box_2->setToolTip("R:" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1])+ "/" + qs[2].setNum(penalty[2])
                                + "\nL:" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1]) + "/" + qs[2].setNum(penalty[2]));
        }
        //only RArm useable
        else if(ui_RArm_combo->currentIndex() == 3)
        {
            ui_WS_box_2->setToolTip("R:" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1])+ "/" + qs[2].setNum(penalty[2])
                                + "\nL:X/X/X");
        }
        //only LArm useable
        else if(ui_LArm_combo->currentIndex() == 3)
        {
            ui_WS_box_2->setToolTip("R:X/X/X\nL:" + qs[0].setNum(penalty[0]) + "/" + qs[1].setNum(penalty[1]) + "/" + qs[2].setNum(penalty[2]));
        }
        //cripple McCripple
        else
        {
            ui_WS_box_2->setToolTip("R:X/X/X\nL:X/X/X");
        }


        penalty[0] = (ui_BS_box_2->text().toInt()+1)/2;
        //Both arms still useable
        if(ui_RArm_combo->currentIndex() == 3 && ui_LArm_combo->currentIndex() == 3)
        {
            ui_BS_box_2->setToolTip("R:" + qs[0].setNum(penalty[0]) + "\nL:" + qs[0].setNum(penalty[0]));
        }
        //only RArm useable
        else if(ui_RArm_combo->currentIndex() == 3)
        {
            ui_BS_box_2->setToolTip("R:" + qs[0].setNum(penalty[0]) + "\nL:X");
        }
        //only LArm useable
        else if(ui_LArm_combo->currentIndex() == 3)
        {
            ui_BS_box_2->setToolTip("R:X\nL:" + qs[0].setNum(penalty[0]));
        }
        //cripple McCripple
        else
        {
            ui_BS_box_2->setToolTip("R:X\nL:X");
        }


        penalty[0] = (ui_S_box_2->text().toInt()+1)/2;
        penalty[1] = max(  (penalty[2]+5)/10 - 5,0  );
        penalty[2] = (ui_S_box_2->text().toInt()+2)/4;
        penalty[3] = max(  (penalty[4]+5)/10 - 5,0  );
        //Both arms still useable
        if(ui_RArm_combo->currentIndex() == 3 && ui_LArm_combo->currentIndex() == 3)
        {
            ui_S_box_2->setToolTip("R&L:" + qs[0].setNum(penalty[0]) + "(" + qs[1].setNum(penalty[1]) + ")"
                + "\nR:" + qs[2].setNum(penalty[2]) + "(" + qs[3].setNum(penalty[3]) + ")"
                + "\nL:" + qs[2].setNum(penalty[2]) + "(" + qs[3].setNum(penalty[3]) + ")" );
        }
        //only RArm useable
        else if(ui_RArm_combo->currentIndex() == 3)
        {
            ui_S_box_2->setToolTip("R&L:X(X)\nR:" + qs[2].setNum(penalty[2]) + "(" + qs[3].setNum(penalty[3]) + ")"
                + "\nL:X(X)" );
        }
        //only LArm useable
        else if(ui_LArm_combo->currentIndex() == 3)
        {
            ui_S_box_2->setToolTip("R&L:X(X)\nR:X(X)\nL:" + qs[2].setNum(penalty[2]) + "(" + qs[3].setNum(penalty[3]) + ")" );
        }
        //cripple McCripple
        else
        {
            ui_S_box_2->setToolTip("R&L:X(X)\nR:X(X)\nL:X(X)"  );
        }

    }
}

void BasicINQ::LegyNotes()
{


    //both legs are healthy
    if(ui_RLeg_combo->currentIndex() < 3 && ui_LLeg_combo->currentIndex() < 3)
    {
        ui_Speed_box_2->setToolTip("Crawl:1\"\nSneak:1\"\nWalk:2\"\nRun:3\"\nSprint:5\"");
    }
    //atleast one leg is outa here
    else if(ui_RLeg_combo->currentIndex() > 3 || ui_LLeg_combo->currentIndex() > 3)
    {
        ui_Speed_box_2->setToolTip("Crawl:1/2\"\nSneak:X\nWalk:X\nRun:X\nSprint:X");
    }
    //atleast one leg is injured
    else
    {
        ui_Speed_box_2->setToolTip("Crawl:1/2\"\nSneak:1/2\"\nWalk:1\"\nRun:1 1/2\"\nSprint:2 1/2\"");
    }
}

void BasicINQ::ToughNotes()
{
    QString qs[4];

    ui_T_box_2->setToolTip("KB:" + qs[0].setNum( (ui_S_box_2->text().toInt()+5)/10 )
                           +"\nIV:" + qs[1].setNum( (ui_T_box_2->text().toInt()+5)/10 )
                           +"\nSS:" + qs[2].setNum( (ui_T_box_2->text().toInt()+2)/5 )
                           +"\nC:" + qs[3].setNum( (ui_T_box_2->text().toInt()+1)/2 ) );
}

void BasicINQ::HealNotes()
{
    QString qs;
    ui_Head_combo->setToolTip("Heal Count: " +    qs.setNum(heal_count.at(char_index).at(HEAD)));
    ui_Chest_combo->setToolTip("Heal Count: " +   qs.setNum(heal_count.at(char_index).at(CHEST)));
    ui_Abdomen_combo->setToolTip("Heal Count: " + qs.setNum(heal_count.at(char_index).at(ABDOMEN)));
    ui_RArm_combo->setToolTip("Heal Count: " +    qs.setNum(heal_count.at(char_index).at(RARM)));
    ui_LArm_combo->setToolTip("Heal Count: " +    qs.setNum(heal_count.at(char_index).at(LARM)));
    ui_Groin_combo->setToolTip("Heal Count: " +   qs.setNum(heal_count.at(char_index).at(GROIN)));
    ui_RLeg_combo->setToolTip("Heal Count: " +    qs.setNum(heal_count.at(char_index).at(RLEG)));
    ui_LLeg_combo->setToolTip("Heal Count: " +    qs.setNum(heal_count.at(char_index).at(LLEG)));
}

void BasicINQ::Notes()
{
    HandyNotes();
    LegyNotes();
    ToughNotes();
    HealNotes();
    //DamageNotes();
}



BasicINQ::~BasicINQ()
{
    delete ui;
}
